package com.qfjy.project.weixin.api.hitokoto;

import com.qfjy.project.weixin.util.WeixinUtil;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Component;

/**
 * @Classname HitokotoUtil
 * @Author guoweixin
 * @Description TODO  一言 一句话服务  https://v1.hitokoto.cn/
 * @Date 2021/6/24 14:15
 * @Created by Administrator
 */
@Component
public class HitokotoUtil {

    private static String HITOKOTO_URL="https://v1.hitokoto.cn/";

    /**
      java jdk原生：UrlConnection
     apache:HttpClient   OKHTTP
     spring框架：RestTemplate
     */
    public String getResult(){
       JSONObject jsonObject= WeixinUtil.httpRequest(HITOKOTO_URL,"GET",null);
       String result=jsonObject.getString("hitokoto");
        return result;
    }
}
